<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #div1 {
            width: 150px;
            height: 150px;
            background-color: #0066cc;
        }
    </style>
    <script type="text/javascript">
        window.onload = function () {
            var div1 = document.getElementById('div1');
            var btn = document.getElementById('btn');
            btn.value = '隐藏';
            div1.style.display = "block";
            btn.onclick = function () {
                if (div1.style.display == "block") {
                    div1.style.display = "none";
                    btn.value = '显示';
                }
                else if (div1.style.display == "none") {
                    div1.style.display = "block";
                    btn.value = '隐藏';
                }
            }
        }
    </script>
</head>
<body>
<input type="button" id="btn">
<div id="div1"></div>

</body>
</html>